<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">

    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <link rel="shortcut icon" href="http://10.168.2.17:81/favicon.ico"/>
    <link rel="bookmark" href="http://10.168.2.17:81/favicon.ico"/>
    <title>厚瞻资产统一登录后台</title>
    <!--必要样式-->
    <link href="/asset/styles.css" rel="stylesheet" type="text/css">
    <script src="/asset/jquery-2.1.1.min.js"></script>
</head>
<body>

<div class="login">

    <form>
        <div class="login_title">
            <span>厚瞻资产统一登录后台</span>
        </div>
        <div class="login_fields">
            <input name="login" placeholder="目标地址" maxlength="16" id="to" type="hidden" autocomplete="off"
                   value="${to}">
            <div class="login_fields__user">
                <div class="icon">
                    <img alt="" src="/asset/user_icon_copy.png">
                </div>
                <input name="login" placeholder="用户名" class="username" id="account" type="text">
            </div>
            <div class="login_fields__password">
                <div class="icon">
                    <img alt="" src="/asset/lock_icon_copy.png">
                </div>
                <input name="pwd" class="passwordNumder" placeholder="密码" id="pass" type="text">
            </div>
            <div class="login_fields__submit">
                <input type="button" value="登录" id="loginBtn">
            </div>
        </div>
        <div class="disclaimer">
            <p>欢迎登陆接入平台</p>
        </div>
    </form>

</div>


<script src="/asset/Particleground.js" type="text/javascript"></script>
<script src="/asset/md5.js" type="text/javascript"></script>

<script>
    $(function () {
        //星星背景初始化
        $('body').particleground({
            dotColor: '#E8DFE8',
            lineColor: '#1b3273'
        });
        //点击事件初始化
        $("#loginBtn").click(function () {
            $(function () {
                $.ajax({
                    //请求方式
                    type: "POST",
                    //请求的媒体类型
                    contentType: "application/json;charset=UTF-8",
                    //请求地址
                    url: "/sso/login/account",
                    //数据，json字符串
                    data: JSON.stringify({
                        "account": $("#account").val(),
                        "pass": md5($("#pass").val()),
                        "to": $("#to").val()
                    }),
                    //请求成功
                    success: function (result) {
                        if (result.code == 200) {
                            window.location.href = result.data.to + (result.data.to.indexOf("?") != -1 ? ("&code=" + result.data.code) : ("?code=" + result.data.code))
                        } else {
                            alert(result.msg)
                        }
                    },
                    //请求失败，包含具体的错误信息
                    error: function (e) {
                        alert("单点授权服务器异常！")
                    }
                });
            });
        })
    })

</script>
</body>
</html>